<extend name="./Application/Home/View/Public/Base/common.html" />
<block name="title">用户管理</block>
<block name="breadcrumb">
    用户管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</block>
<block name="body">
    <style>
        .mk-blue{
            color: #00a2d4;
        }

        .mk-hasbtn{
            margin-top: 45px;
            position: relative;
        }

        .page-nation-botton,.page-nation-up,.page-nation-down{
            width: 30px;
            height: 30px;
            border: 1px solid #dcdcdc;
            display: inline-block;
            margin-top: 2px;
            text-align: center;
            line-height: 30px;
            border-radius: 3px;
            cursor: pointer;
        }

        .page-nation-up,.page-nation-down{
            width: 50px;
        }

        #pageNation{
            height: 35px;
            position: absolute;
            right: 0px;
            bottom: -50px;
        }


        .table th,.table td{
            font-size: 13px;
        }

        .table th{
            background: #E0EAF6 !important;
        }

        .button-img{
            width: 18px;
            margin-bottom: 2px;
            margin-right: 5px;
        }

    </style>
    <article class="cl pd-20">
        <div id="kkk" style="width:90%;margin-top: -5px;text-align: center">
            <table class="table  table-hover table-bg table-sort">
              <span class="l r" style="position: absolute;left: 30px;">
                    <a href="javascript:;" onclick="add()" class="btn radius" style="background: #F5F8F9;"><img  class="button-img" src="__HUI__/images/t01.png">添加</a>
              </span>
              <span class="l r" style="position: absolute;left: 130px;">
                  <a href="javascript:;" onclick="delAll()" style="background: #F5F8F9;" class="btn radius"><img class="button-img" src="__HUI__/images/t03.png">删除</a>
              </span>
            </table>
        </div>
        <div class="mt-20 mk-hasbtn">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                <tr class="text-c">
                    <th width="3%"><input type="checkbox" name="" value=""></th>
                    <th width="24%">用户标识ID</th>
                    <th width="25%">用户国标标识ID</th>
                    <th width="24%">用户名</th>
                    <th width="24%">操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="array['accounts']" id = 'row' key="k">
                    <tr class="text-c">
                        <td><input type="checkbox" value="{$row['accountid']}" name=""></td>
                        <td>{$row['accountid']}</td>
                        <td>{$row['usergbid']}</td>
                        <td>{$row['username']}</td>
                        <td class="f-14 td-manage"><a style="text-decoration:none" class="mk-blue" onClick="modify('{$row[accountid]}')" href="javascript:;" title="修改">修改密码</a></td>
                    </tr>
                </volist>
                </tbody>
                <div id="pageNation">
                    <if condition="($pagesum gt 1) AND ($page neq 1)">
                        <span class="page-nation-up" onclick="pageUp();">上一页</span>
                    </if>
                    <if condition="$pagesum gt 1">
                        <for start="0" end="$pagesum">
                            <span class="page-nation-botton" onclick="pageGo({$i+1});">{$i+1}</span>
                        </for>
                    </if>
                    <if condition="($pagesum gt 1) AND ($pagesum gt $page)">
                        <span class="page-nation-down" onclick="pageDown();">下一页</span>
                    </if>
                    <if condition="$pagesum gt 1">
                        <span style="display: inline-block;width: 50px;border: 1px solid #cccccc;text-align: center;border-radius: 3px;background: rgb(219, 247, 253);">共{$pagesum}页</span>
                    </if>
                </div>
            </table>
        </div>
    </article>
    <script type="text/javascript">
        var page = 1;
        if({$page}){
            page = {$page};
        }
        setTimeout(function(){
            $(".page-nation-botton").each(function(){
                if($(this).text() == page){
                    $(this).css("background","#DBF7FD");
                }else{
                    $(this).css("background","white");
                }
            })
        },200);

        var add = function(){
            layer.open({
                type: 2,
                area: ['500px', '450px'],
                fixed: true,
                content: "{:U('Home/SipUser/setAddUser')}"
            });
        }

        var modify = function(id){
            layer.open({
                type: 2,
                area: ['500px', '450px'],
                fixed: true,
                content: "{:U('Home/SipUser/UserOne')}"+"?accountid="+id
            });
        }

        var delAll = function(){
            layer.confirm('确认要全部删除吗？',{icon:3},function(){
                $("table input").each(function(){
                    if($(this)[0].checked == true){
                        var pop = $(this)[0].value;
                        $.ajax({
                            type : "POST",
                            url : "{:U('Home/SipUser/UserDel')}",
                            data: {accountid:pop},
                            dataType : "json",
                            success : function (data) {
                            }
                        });
                    }
                });
                layer.msg('已删除!',{icon:1,time:500});
                setTimeout(function(){
                    window.location.href=window.location.href;
                },800);
            });
        }


        //上一页
        function pageUp() {
            var num;
            if(page==1){
                num = page;
            }else{
                num = page-1;
            }
            window.location.href = "{:U('Home/SipUser/userList')}"+"?page="+num;
        }

        //下一页
        function pageDown(){
            var num;
            if({$pagesum} == page){
                num = page;
            }else{
                num = page+1;
            }
            window.location.href = "{:U('Home/SipUser/userList')}"+"?page="+num;
        }

        //指定页
        function pageGo(num) {
            page = num;
            window.location.href = "{:U('Home/SipUser/userList')}"+"?page="+num;
        }

    </script>
</block>